﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Lant.Net.Model
{
	public class Puker
	{
		private List<PukeCard> all;
		private PukeInfo info;
		private PukerMode mode;
		public Puker(PukeInfo info, PukerMode mode)
		{
			this.info = info;
			this.mode = mode;
		}
		public bool Start()
		{
			all = new List<PukeCard>();
			int pukeCount = 1;
			int pukeCardCount = 0;
			switch (mode)
			{
				case PukerMode.puke52:
					pukeCardCount = 52;
					break;
				case PukerMode.puke54:
					pukeCardCount = 54;
					break;
				default:
					break;
			}
			for (int i = 0; i < pukeCardCount; i++)
			{
				//info = new PukeInfo30x40();
				all.Add(new PukeCard(info, i));
			}
			Random random = new Random();
			PukeCard temp = null;
			for (int i = 0; i < pukeCardCount * pukeCount; i++)
			{
				int n = random.Next(pukeCardCount * pukeCount - i);
				temp = all[i];
				all[i] = all[n];
				all[n] = temp;
			}
			return true;
		}
		public List<PukeCard> GetPukeCard(int pukeCount)
		{
			if (pukeCount > all.Count) pukeCount = all.Count;
			List<PukeCard> tempCard = new List<PukeCard>();
			for (int i = pukeCount - 1; i >= 0; i--)
			{
				tempCard.Add(all[i]);
				all.Remove(all[i]);
			}
			return tempCard;
		}
		public int GetSparePukeCount 
		{
			get { return all.Count; }
		}
	}
}
